//
// Created by wang on 2021/6/29.
//

#ifndef ENET_ETYPES_H
#define ENET_ETYPES_H


/* Basic type definitions */

#include <stdint.h>

typedef uint8_t byte;
typedef uint16_t word;
typedef uint32_t dword;

typedef uint32_t ret_t;

#define true 1
#define false 0

/* enet types */

#if defined(_WIN32)
#   include <winsock2.h>
#   include <in6addr.h>
#   include <ws2tcpip.h>
#else
#   include <arpa/inet.h>
#endif
#define IP_MAX_STR_LEN (15 + 1)
typedef struct {
    struct in_addr ip;
    uint32_t ip_mask;
    char ip_str[IP_MAX_STR_LEN];
}ip_node;
#define NODE_CMP_IP(n, i) ((n).ip.s_addr == (i).s_addr)
#define NODE_CMP_NODE(n1, n2) ((n1).ip.s_addr == (n2).ip.s_addr)
#define NODE_CMP_NODE_MSK(n1, n2) ((n1).ip_mask == (n2).ip_mask)
#define NODE_CMP_NODE_STRICT(n1, n2) \
(NODE_CMP_NODE((n1), (n2)) && NODE_CMP_NODE_MSK((n1), (n2)))



#define MAC_LEN 6
#define MAX_FRAME_LEN 1500

typedef byte mac[MAC_LEN];
typedef struct {
    byte rx[MAX_FRAME_LEN];
}rx_chain;


#endif //ENET_ETYPES_H
